﻿<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="RestManagement.aspx.cs" Inherits="Admin_RestManagement" Title="Manage Restaurants" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">
<telerik:RadCodeBlock ID="block1" runat="server">
    <script type="text/javascript">
        function OpenPositionedWindow(oButton, url, windowName) {
            var oWnd = window.radopen(url, windowName);
        }
        function openRadWindow(RestID) {
            var dialogs = $find('<%=InfoBox.ClientID %>').get_windows();
            var detailPage = dialogs[0];
            detailPage.setUrl("Details.aspx?RestID=" + RestID);
            //            detailPage.SetWidth(widthPage);
            //            detailPage.SetHeight(heightPage);
            detailPage.show();
        }
        function OnClientFocus(sender) {
            var combo = $find('<%=RadComboBox1.ClientID %>');
            var content = combo.get_text();
            if (content == "Nhập vào từ khóa cần tìm") {
                combo.set_text("");
            }
        }
        function OnClientBlur(sender, args) {
            var combo = $find('<%=RadComboBox1.ClientID %>');
            var content = combo.get_text();
            if (content == "") {
                combo.set_text("Nhập vào từ khóa cần tìm");
            }
        }
    </script>
</telerik:RadCodeBlock>
    <div>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:EatDrinkConnectionString %>" 
            SelectCommand="SELECT * FROM [Location]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:EatDrinkConnectionString %>" 
            SelectCommand="SELECT * FROM [Restaurant]"></asp:SqlDataSource>
        <div align="right">
            <telerik:radcombobox 
                id="RadComboBox1" 
                Runat="server" 
                Height="140px" 
                Width="250px"
                ForeColor="#BDBDBD"
                DataSourceID="SqlDataSource2" 
                DataTextField="RestName"
                ToolTip="Chọn tên nhà hàng"
                Skin="Outlook"
                AllowCustomText = "true"
                MarkFirstMatch="True" OnDataBound="RadComboBox1_DataBound"
                OnClientFocus="OnClientFocus"
                OnClientBlur="OnClientBlur">
            </telerik:radcombobox>&nbsp;&nbsp;
            <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" Height="21px" OnClick="btnSearch_Click"/>
        </div>
        <telerik:RadGrid ID="uxRestList" runat="server" Skin="WebBlue" AutoGenerateColumns="false"
            AllowPaging="true" PageSize="30" AllowSorting="true" ShowStatusBar="true" PagerStyle-Mode="NextPrevNumericAndAdvanced"
            OnNeedDataSource="uxRestList_NeedDataSource" OnItemDataBound="uxRestList_ItemDataBound"
            OnUpdateCommand="uxRestList_UpdateCommand" OnInsertCommand="uxRestList_InsertCommand"
            OnDeleteCommand="uxRestList_DeleteCommand" 
            onitemcommand="uxRestList_ItemCommand">
            <MasterTableView DataKeyNames="RestID" CommandItemDisplay="TopAndBottom" ClientDataKeyNames="RestID">
                <CommandItemTemplate>
                    <asp:LinkButton Style="vertical-align: bottom" ID="btnViewAll" runat="server"
                        CausesValidation="false" CommandName="ViewAll" ForeColor="#58ACFA">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Images/view.gif" height="10" width="10"/>&nbsp;Xem tất cả
                    </asp:LinkButton>&nbsp;&nbsp;
                    <asp:LinkButton Style="vertical-align: bottom" ID="btnRefresh" runat="server"
                        CausesValidation="false" CommandName="RebindGrid" ForeColor="#58ACFA">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Refresh.gif" height="9" width="9"/>&nbsp;Refresh
                    </asp:LinkButton>&nbsp;&nbsp;
                    <asp:LinkButton Style="vertical-align: bottom" ID="LinkButton1" runat="server"
                        CausesValidation="false" CommandName="InitInsert" ForeColor="#58ACFA">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Images/AddRecord.gif" height="10" width="10"/>&nbsp;Thêm nhà hàng mới
                    </asp:LinkButton>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                            <a href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"RestID")%>'); return false;">
                            Chi tiết</a>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn Visible="false" HeaderText="RestID" UniqueName="RestID"
                        DataField="RestID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="RestName" UniqueName="RestName" DataField="RestName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Category" UniqueName="RestCat" DataField="RestCat">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Address" UniqueName="Address" DataField="Address">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="ServedTime" UniqueName="ServedTime" DataField="ServedTime">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="IsActivated" HeaderText="IsActivated" UniqueName="IsActivated">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridButtonColumn CommandName="Delete" Text="Xóa" UniqueName="Delete" ConfirmDialogType="RadWindow"
                        ConfirmText="Are you sure you would like to delete this?" ConfirmTitle="Delete">
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table>
                            <tr>
                                <td>
                                    <b>RestName</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtRestName" runat="server" Text='<%#Eval("RestName")%>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="(*)" ControlToValidate="txtRestName"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Category</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtRestCat" runat="server" Text='<%#Eval("RestCat")%>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Address</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAddress" runat="server" Text='<%#Eval("Address")%>' TextMode="MultiLine" Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Address Description</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAddressDescription" runat="server" Text='<%#Eval("AddressDescription")%>' TextMode="MultiLine" Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Slogan</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtSlogan" runat="server" Text='<%#Eval("Slogan")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Short Description</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtShortDescription" runat="server" Text='<%#Eval("ShortDescription")%>' TextMode="MultiLine" Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Long Description</b>
                                </td>
                                <td>
                                    <div id="divLongDescription" runat="server">
                                        <telerik:RadEditor Skin="Office2007" Height="600px" ID="RadEditor1" runat="server"
                                            Enabled="true" Width="500px" EnableViewState="false">
                                            <ImageManager ViewPaths="~/Images/Restaurants" />
                                            <FlashManager ViewPaths="~/Images/Restaurants" />
                                            <Tools>
                                                <telerik:EditorToolGroup>
                                                    <telerik:EditorTool Name="LinkManager" />
                                                    <telerik:EditorTool Name="ImageManager" />
                                                    <telerik:EditorSeparator />
                                                    <telerik:EditorTool Name="FontName" />
                                                    <telerik:EditorTool Name="FontSize" />
                                                    <telerik:EditorSeparator />
                                                    <telerik:EditorTool Name="Bold" />
                                                    <telerik:EditorTool Name="Italic" />
                                                    <telerik:EditorTool Name="Underline" />
                                                    <telerik:EditorSeparator />
                                                    <telerik:EditorTool Name="ForeColor" />
                                                    <telerik:EditorTool Name="BackColor" />
                                                    <telerik:EditorSeparator />
                                                    <telerik:EditorTool Name="InsertOrderedList" />
                                                    <telerik:EditorTool Name="InsertUnorderedList" />
                                                    <telerik:EditorTool Name="Indent" />
                                                    <telerik:EditorTool Name="Outdent" />
                                                </telerik:EditorToolGroup>
                                            </Tools>
                                        </telerik:RadEditor>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Location</b>
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlLocation" runat="server" AppendDataBoundItems="true" DataSourceID="SqlDataSource1" DataValueField="LocationID" DataTextField="District" SelectedValue='<%# Eval("LocationID") %>'>
                                        <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Phone Number</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtPhoneNumber" runat="server" Text='<%#Eval("PhoneNumber")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Email</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtEmail" runat="server" Text='<%#Eval("Email")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Fax</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtFax" runat="server" Text='<%#Eval("Fax")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Website</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtWebsite" runat="server" Text='<%#Eval("Website")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Number of Seats</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtSeatCount" runat="server" Text='<%#Eval("SeatCount")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>IsOrder</b>
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlIsOrder" runat="server" AppendDataBoundItems="true" DataSource='<%# (new string[] {"Chấp nhận", "Không nhận"})%>' SelectedValue='<%# Eval("IsOrder") %>'>
                                        <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>OffDate</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtOffDate" runat="server" Text='<%#Eval("OffDate")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>ServedTime</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtServedTime" runat="server" Text='<%#Eval("ServedTime")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>PaymentType</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtPaymentType" runat="server" Text='<%#Eval("PaymentType")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Language</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtLanguage" runat="server" Text='<%#Eval("Language")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>AveragePrice</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAveragePrice" runat="server" Text='<%#Eval("AveragePrice")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>SubServices</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtSubServices" runat="server" Text='<%#Eval("SubServices")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Menu</b>
                                </td>
                                <td>
                                    <telerik:RadEditor Skin="Office2007" Height="600px" ID="RadEditor2" runat="server"
                                        Enabled="true" Width="700px" EnableViewState="false">
                                        <ImageManager ViewPaths="~/Images/Restaurants" />
                                        <FlashManager ViewPaths="~/Images/Restaurants" />
                                        <Tools>
                                            <telerik:EditorToolGroup>
                                                <telerik:EditorTool Name="LinkManager" />
                                                <telerik:EditorTool Name="ImageManager" />
                                                <telerik:EditorSeparator />
                                                <telerik:EditorTool Name="FontName" />
                                                <telerik:EditorTool Name="FontSize" />
                                                <telerik:EditorSeparator />
                                                <telerik:EditorTool Name="Bold" />
                                                <telerik:EditorTool Name="Italic" />
                                                <telerik:EditorTool Name="Underline" />
                                                <telerik:EditorSeparator />
                                                <telerik:EditorTool Name="ForeColor" />
                                                <telerik:EditorTool Name="BackColor" />
                                                <telerik:EditorSeparator />
                                                <telerik:EditorTool Name="InsertOrderedList" />
                                                <telerik:EditorTool Name="InsertUnorderedList" />
                                                <telerik:EditorTool Name="Indent" />
                                                <telerik:EditorTool Name="Outdent" />
                                            </telerik:EditorToolGroup>
                                        </Tools>
                                        <Content>
                                            <table width="663" border="1">
                                                <tr align="center">
                                                    <td style="font-weight: bold; width: 331px">Nhập vào tên món ăn ở đây</td>
                                                    <td style="font-weight: bold; width: 332px">Nhập vào giá tiền tương ứng với món ăn ở đây</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <tr align="center">
                                                    <td>&nbsp;</td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                            </table>
                                        </Content>
                                    </telerik:RadEditor>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Note</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtNote" runat="server" Text='<%#Eval("Note")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Search</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtSearch" runat="server" Text='<%#Eval("Search")%>' TextMode="MultiLine" Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>ImageFolderName</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtImageFolderName" runat="server" Text='<%#Eval("ImageFolderName")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Flash</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtFlash" runat="server" Text='<%#Eval("Flash")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Order</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtOrder" runat="server" Text='<%#Eval("Order")%>' Width="200px"></asp:TextBox><br />
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Chỉ chấp nhận dữ liệu là số" ControlToValidate="txtOrder" ValidationExpression="\d*" Display="Dynamic"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>UserID</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtUserID" runat="server" Text='<%#Eval("UserID")%>' Width="200px"></asp:TextBox><br />
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Chỉ chấp nhận dữ liệu là số" ControlToValidate="txtUserID" ValidationExpression="\d*" Display="Dynamic"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>IsActivated</b>
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlIsActivated" runat="server" AppendDataBoundItems="true" DataSource='<%# (new string[] {"True", "False"})%>' SelectedValue='<%# Eval("IsActivated") %>'>
                                        <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Url</b>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtUrl" runat="server" Text='<%#Eval("Url")%>' Width="200px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <%--<asp:LinkButton ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </asp:LinkButton>--%>
                                    <%--<asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:LinkButton>--%>
                                    <asp:Button ID="btnUpdate" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'/>&nbsp;
                                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" CommandName="Cancel"/>
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadWindowManager ID="InfoBox" runat="server" 
            VisibleStatusbar="false">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" Title="Restaurant Details" NavigateUrl="Details.aspx"
                    runat="server" Width="800" Height="400" Modal="true" VisibleStatusbar="true">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server" Height="75px"
            Width="75px">
            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
                style="border: 0px;" />
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxManager ID="RadAjaxManager" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="uxRestList">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="uxRestList" />
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
    </div>
</asp:Content>
